// eslint-disable-next-line
import { UserLayout, BasicLayout, BlankLayout } from '@/layouts'
import { bxAnaalyse } from '@/core/icons'

const RouteView = {
  name: 'RouteView',
  render: (h) => h('router-view')
}

export const asyncRouterMap = [
  {
    path: '/',
    name: 'index',
    component: BasicLayout,
    meta: { title: '首页' },
    redirect: '/products/productsmam',
    children: [
      // dashboard
      {
        path: '/dashboard',
        name: 'dashboard',
        redirect: '/dashboard/Analysis',
        component: RouteView,
        meta: { title: 'menu.dashboard', keepAlive: true, icon: bxAnaalyse, permission: [ 'dashboard' ] },
        children: [
          {
            path: '/dashboard/analysis/:pageNo([1-9]\\d*)?',
            name: 'Analysis',
            component: () => import('@/views/dashboard/Analysis'),
            meta: { title: 'menu.dashboard.analysis', keepAlive: false, permission: [ 'dashboard' ] }
          },
          {
            path: '/dashboard/workplace',
            name: 'Workplace',
            component: () => import('@/views/dashboard/Workplace'),
            meta: { title: 'menu.dashboard.workplace', keepAlive: true, permission: [ 'dashboard' ] }
          }
        ]
      },
      {
        path: '/products',
        name: 'products',
        redirect: '/products/productsmam',
        component: RouteView,
        meta: { title: '产品中心', keepAlive: true, icon: bxAnaalyse, permission: [ '*' ] },
        children: [
          {
            path: '/products/productsmam',
            name: 'productsmam',
            component: () => import('@/views/products/productsmam'),
            meta: { title: '产品管理', keepAlive: false, icon: bxAnaalyse, permission: [ '*' ] }
          },
          {
            path: '/products/add',
            name: 'Add',
            component: () => import('@/views/products/add'),
            meta: { title: '发布产品', keepAlive: false, icon: bxAnaalyse, permission: [ '*' ] }
          },
          {
            path: '/products/errormsg',
            name: 'Errormsg',
            component: () => import('@/views/products/errormsg'),
            meta: { title: '报错消息', keepAlive: false, icon: bxAnaalyse, permission: [ '*' ] }
          }
        ]
      },
      {
        path: '/finance',
        name: 'finance',
        redirect: '/finance/recharge',
        component: RouteView,
        meta: { title: '财务管理', keepAlive: true, icon: bxAnaalyse, permission: [ '*' ] },
        children: [
          {
            path: '/finance/recharge',
            name: 'recharge',
            component: () => import('@/views/finance/recharge'),
            meta: { title: '充值页', keepAlive: false, icon: bxAnaalyse, permission: [ '*' ] }
          },
          {
            path: '/finance/detail',
            name: 'Detail',
            component: () => import('@/views/finance/detail'),
            meta: { title: '账号明细', keepAlive: false, icon: bxAnaalyse, permission: [ '*' ] }
          },
          {
            path: '/finance/serveaudit',
            name: 'Serveaudit',
            component: () => import('@/views/finance/serveaudit'),
            meta: { title: '服务费审核', keepAlive: false, icon: bxAnaalyse, permission: [ '*' ] }
          }
        ]
      },
      {
        path: '/product',
        name: 'product',
        redirect: '/product/productsmam',
        component: RouteView,
        meta: { title: '产品中心', keepAlive: true, icon: bxAnaalyse, permission: [ '*' ] },
        children: [
          {
            path: '/product/productsmam',
            name: 'productsma',
            component: () => import('@/views/product/productsmam'),
            meta: { title: '产品管理', keepAlive: false, icon: bxAnaalyse, permission: [ '*' ] }
          }

        ]
      },
      {
        path: '/account',
        name: 'account',
        redirect: '/account/isupgoods',
        component: RouteView,
        meta: { title: '账号管理', keepAlive: true, icon: bxAnaalyse, permission: [ '*' ] },
        children: [
          {
            path: '/account/isupgoods',
            name: 'isupgoods',
            component: () => import('@/views/account/isupgoods'),
            meta: { title: '上单权限', keepAlive: false, icon: bxAnaalyse, permission: [ '*' ] }
          }

        ]
      }

    ]
  },
  {
    path: '*', redirect: '/404', hidden: true
  }
]

/**
 * 基础路由
 * @type { *[] }
 */
export const constantRouterMap = [
  {
    path: '/user',
    component: UserLayout,
    redirect: '/user/login',
    hidden: true,
    children: [
      {
        path: 'login',
        name: 'login',
        component: () => import(/* webpackChunkName: "user" */ '@/views/user/Login')
      },
      {
        path: 'register',
        name: 'register',
        component: () => import(/* webpackChunkName: "user" */ '@/views/user/Register')
      },
      {
        path: 'register-result',
        name: 'registerResult',
        component: () => import(/* webpackChunkName: "user" */ '@/views/user/RegisterResult')
      },
      {
        path: 'recover-result',
        name: 'recoverResult',
        component: () => import(/* webpackChunkName: "user" */ '@/views/user/RecoverResult')
      },
      {
        path: 'recover',
        name: 'recover',
        component: () => import(/* webpackChunkName: "user" */ '@/views/user/Recover')
      }
    ]
  },

  {
    path: '/404',
    component: () => import(/* webpackChunkName: "fail" */ '@/views/exception/404')
  }

]
